﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data;
using System.Linq;
using System.Text;
using DomainDriver.DomainModeling.DomainObjects;
using DomainDriver.DomainModeling.StorageManagers.DataSetStorage;
using DomainDriver.DomainModeling.StorageManagers.EntityFrameworkStorage;
using ObjectRow = AutomotivePricingModel.ValueObjects.MissingValueOptions.MissingValueOptionsDataSet.MissingValueOptionsRow;

namespace AutomotivePricingModel.ValueObjects.MissingValueOptions
{
    public partial class MissingValueOption : IEfEntity<int>, IDataSetSerializable<DataSet, DataRow>
    {
        #region ADO .NET Entities Framework Storage

        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.None)]
        public int EF_Id
        {
            get { return (int)m_Key; }
            set { m_Key = (MissingValueOptionEnum)value; }
        }

        #endregion

        #region AutomotivePricingDataSet Serialization

        public string ObjectTableName
        {
            get { return MissingValueOptionsDataSet.SchemaHelper.MissingValueOptions.TableName; }
        }

        public string KeyColumnName
        {
            get { return MissingValueOptionsDataSet.SchemaHelper.MissingValueOptions.MissingValueOptionIdColumn.ColumnName; }
        }

        private string DisplayNameColumnName
        {
            get { return MissingValueOptionsDataSet.SchemaHelper.MissingValueOptions.DisplayNameColumn.ColumnName; }
        }

        public void Serialize(DataSet datasource, DataRow dataRow)
        {
            dataRow[KeyColumnName] = (int)m_Key;
            dataRow[DisplayNameColumnName] = m_DisplayName;
        }

        public void Deserialize(DataSet datasource, DataRow dataRow)
        {
            m_Key = (MissingValueOptionEnum)dataRow[KeyColumnName];
            m_DisplayName = (string)dataRow[DisplayNameColumnName];
        }

        #endregion
    }
}